using UnityEngine;
using System.Collections;

public class Accept : MonoBehaviour 
{
	public CharacterMove move;
	public TextMesh[] texts;
	public GameObject player;
	int count;
	string text;
	void Update()
	{
		move.enabled = false;
		
		if(Input.GetAxis("Vertical") > 0 && count > 0)
		{
			texts[count].renderer.material.color = Color.white;
			count --;
			texts[count].renderer.material.color = Color.red;
		}
		if(Input.GetAxis("Vertical") < 0 && count < 1)
		{
			texts[count].renderer.material.color = Color.white;
			count ++;
			texts[count].renderer.material.color = Color.red;
		}
		
		if(Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
		{
			if(count == 0)
			{
				move.enabled = true;
				player.SendMessage("reactMessage",text);
				texts[count].renderer.material.color = Color.white;
				gameObject.SetActiveRecursively(false);
			}
			if(count == 1)
			{
				move.enabled = true;
				player.SendMessage("reactMessage","");
				texts[count].renderer.material.color = Color.white;
				gameObject.SetActiveRecursively(false);
			}
		}
		
		
	}
	
	void ReceivedText(string texting)
	{
		text = texting;
		count = 0;
		texts[count].renderer.material.color = Color.red;
	}
}
